package com.jyy.prefabricated.service.impl;

import com.jyy.prefabricated.entity.EligibilityRules;
import com.jyy.prefabricated.mapper.EligibilityRulesMapper;
import com.jyy.prefabricated.service.EligibilityRulesService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 考试合格规则表(EligibilityRules)表服务实现类
 *
 * @author mrl
 * @since 2021-07-07 16:19:02
 */
@Service("eligibilityRulesService")
public class EligibilityRulesServiceImpl implements EligibilityRulesService {
    @Resource
    private EligibilityRulesMapper eligibilityRulesDao;

    /**
     * 通过ID查询单条数据
     *
     * @param erId 主键
     * @return 实例对象
     */
    @Override
    public EligibilityRules queryById(Integer erId) {
        return this.eligibilityRulesDao.queryById(erId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<EligibilityRules> queryAllByLimit(int offset, int limit) {
        return this.eligibilityRulesDao.queryAllByLimit(offset, limit);
    }

    @Override
    public List<EligibilityRules> queryAll(EligibilityRules eligibilityRules) {
        return eligibilityRulesDao.queryAll(eligibilityRules);
    }

    /**
     * 新增数据
     *
     * @param eligibilityRules 实例对象
     * @return 实例对象
     */
    @Override
    public EligibilityRules insert(EligibilityRules eligibilityRules) {
        this.eligibilityRulesDao.insert(eligibilityRules);
        return eligibilityRules;
    }

    /**
     * 修改数据
     *
     * @param eligibilityRules 实例对象
     * @return 实例对象
     */
    @Override
    public EligibilityRules update(EligibilityRules eligibilityRules) {
        this.eligibilityRulesDao.update(eligibilityRules);
        return this.queryById(eligibilityRules.getErId());
    }

    /**
     * 通过主键删除数据
     *
     * @param erId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer erId) {
        return this.eligibilityRulesDao.deleteById(erId) > 0;
    }
}